<?php
//NÃ£o mostra as mensagens de alerta
$display_success = $display_error = "style='display: none'";

if($msg != ''){

    if($msg_type == "ok")
        $display_success = ''; //mostrar mensagem de sucesso
    else
        $display_error = ''; // mostrar mensagem de erro
}



?>
<script type="text/javascript" src="assets/js/usuario/usuario.js" charset="utf-8"></script>
<div class="container">
	<h3 class="text-info">Usuarios</h3>

	
	<div class="span3">
				
		<h4 class="muted">Categorias</h4>
		<p><a href="#nova_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-plus"></i> Nova categoria</a></span></p>
		<ul class="nav nav-tabs nav-stacked">
	    <?php foreach($categoria_usuario as $categoria){ ?>
  			<li onclick="get_usuario_por_categoria(this,'<?php echo $categoria->categoria_id?>');">
  			    <a><?php echo $categoria->categoria_nome ?> <i class="icon-chevron-right pull-right"></i></a>
		    </li>
		<?php } ?>
		</ul>
	
	</div>
	
	
	<div class="span7">
		
		<h4 class="muted">Titulo da categoria</h4>
		<p><a href="#novo_usuario_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-plus"></i> Novo usuario</span></a> <a href="#editar_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-refresh"></i> Editar categoria</span></a> <a href="#excluir_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-remove"></i> Excluir categoria</span></a></p>
		
		
	
			
		<div class="alert alert-success fade in" <?php echo $display_success ?>>
				<button type="button" class="close" data-dismiss="alert"><i class="icon-remove"></i> </button>
				<strong>Sucesso!</strong>
				<p id="msg_succ"><?php echo $msg ?></p>
		</div>	
		<div class="alert alert-error fade in" <?php echo $display_error ?>>
				<button type="button" class="close" data-dismiss="alert"><i class="icon-remove"></i> </button>
				<strong>Erro!</strong>
				<p id="msg_error"><?php echo $msg ?></p>
		</div>
	</div>
	<div id="user-info-container">
	    <!-- AQUI SERÃ� CARREGADO AS INFORMAÃ‡Ã•ES DO USUARIO POR CATEGORIA -->
	</div>
	
		
		<!-- MODAL DE CADASTRO DE USUARIO-->
		<div class="modal fade" id="novo_usuario_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Cadastrar Usuário</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/users/usuarios/cadastrar_usuario" onsubmit="return validate_password();">
						<label><span class="text-error">*</span> <input type="text" id="nome" name="nome"  class="span4" required="required" placeholder="Nome" /> </label>
						<label><span class="text-error">*</span> <input type="email" id="email" name="email" class="span4" required="required" placeholder="Email"/> </label>
						<label><span class="text-error">*</span> <input type="text" id="username" name="username" class="span4" required="required" placeholder="Username"/> </label>
						<label><span class="text-error">*</span> <input type="password" id="senha" name="senha" class="span4" required="required" placeholder="Senha"/> </label>
						<label><span class="text-error">*</span> <input type="password" id="confirm_senha" name="confirm_senha" class="span4" required="required" placeholder="Repita a senha"/> </label>
						<label><span class="text-error">*</span> Categoria: 
								 <select required name="categoria" id="categoria">
		                                <option value=""> Selecione uma categoria</option>
		                                <?php foreach($categoria_usuario as $categoria){?>
		                                 <option value="<?php echo $categoria->categoria_id ?>"><?php echo $categoria->categoria_nome ?></option>
		                                <?php    
		                                }
		                                ?>
		                          </select>
						</label>
						<label><span class="text-error">*</span> Tipo de usuário:</label>
						<label><input type="radio" name="tuser" value="administrador"/> Administrador</label>
						<label><input type="radio" name="tuser" checked="checked" value="normal"/> Normal</label>
						<hr>
						<label><button type="submit" class="btn btn-primary">Cadastrar</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		<!-- MODAL DE NOVA CATEGORIA-->
			
		<div class="modal fade" id="nova_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Cadastrar categoria</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/users/usuarios/cadastrar_usuario" onsubmit="return validate_password();">
						<label> <span class="text-error">*</span> <input type="text" name="nome" id="nome" required="required" class="span4"  placeholder="Nome da categoria"/> </label>
						<hr>
						<label><button type="submit" class="btn btn-primary">Cadastrar</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->	
			
		<!-- MODAL DE EDIÇÃO DA CATEGORIA-->
			
		<div class="modal fade" id="editar_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Editar categoria</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/users/usuarios/cadastrar_usuario">
						<label> <span class="text-error">*</span> <input type="text" name="nome" id="nome" required="required" class="span4"  placeholder="Nome da categoria" value="Nome antigo"/> </label>
						
						<hr>
						<label><button type="submit" class="btn btn-primary">Editar</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		
		
		<!-- MODAL DE EXCLUSÃO DA CATEGORIA-->
			
		<div class="modal fade" id="excluir_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Exluir categoria</h3>
		      </div>
		      <div class="modal-body">
		      	<span>Deseja mesmo exluir a categoria Categoria?</span>
		        <form method="post" action="index.php/users/usuarios/cadastrar_usuario">
						<hr>
						<label><button type="submit" class="btn btn-success">Confirma</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->	
			
			
		</div>
	</div>
</div>

<!-- MODAL DE CONFIRMAÃ‡Ã‚O -->
<div class="modal fade" id="modal_confirm_delete" style="display: none">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Excluir UsuÃ¡rio?</h4>
      </div>
      <div class="modal-body">
        <p id="modal-text">Deseja realmente excluir o usuÃ¡rio?</p>
        <input type="hidden" id="user_id" />
        <input type="hidden" id="user_category" />
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-success" data-dismiss="modal" onclick="remover_usuario()">Confirmar</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


